import 'package:get/get.dart';

import '../api/addressApi.dart';
import '../model/address_entity.dart';


class UpdateController extends GetxController {
  RxList<AddressEntity> addressList = <AddressEntity>[].obs;

  @override
  void onInit() {
    super.onInit();
    getGoodsList();
  }

  Future<void> getGoodsList() async {
    var res = await getAddressesApi();
    // 清空所有
    addressList.clear();
    res["data"].forEach((item) => addressList.add(AddressEntity.fromJson(item)));
  }

  Future<void> delete(int id) async {
    await deleteByIdApi(id);
    await getGoodsList();
  }
}

